/**
 * 获取一个元素
 * @param  {[string]} ele [description]
 * @return {node}     [description]
 */
function $(ele) {
    return document.querySelector(ele);
}

/**
 * 获取所有元素
 * @param  {string} ele [description]
 * @return {nodeList}     [description]
 */
function $All(ele) {
    return document.querySelectorAll(ele);
}

/**
 * 获取范围之间的随机数
 * @param  {number} min [description]
 * @param  {number} max [description]
 * @return {number}     [description]
 */
function random(min, max) {
    return Math.floor(Math.random() * (max - min + 1) + min);
}




/**
 * 碰撞检测
 * @param  {obj} a [description]
 * @param  {obj} b [description]
 * @return {boolean}   [description]
 */
function crash(a, b) {
    var L1 = a.offsetLeft;
    var R1 = a.offsetLeft + a.offsetWidth;
    var T1 = a.offsetTop;
    var B1 = a.offsetTop + a.offsetHeight;


    var L2 = b.offsetLeft;
    var R2 = b.offsetLeft + b.offsetWidth;
    var T2 = b.offsetTop;
    var B2 = b.offsetTop + b.offsetHeight;

    return !(L2 > R1 || R2 < L1 || T2 > B1 || B2 < T1);
}